<?php
/**
 * Data model
 *
 * @category  DataModel
 * @package   DataModel
 * @author    DataModel Generator v1.3
 * @version   Revision: $Rev$
 */
/**
 * Data model for table "pfolder"
 *
 * @category  DataModel
 * @package   DataModel
 * @author    DataModel Generator v1.3
 * @version   Revision: $Rev$
 *
 * @property-read mixed Id
 * @property-read mixed ParentId
 * @property-read mixed Name
 * @property-read mixed Path
 * @property-read mixed ProjectId
 */
abstract class BasePfolder extends BaseRecord
{
    const TABLE_NAME = "pfolder";

    public function __construct()
    {
        parent::__construct(self::TABLE_NAME);
    }

    protected function initFields()
    {
        $this->hasColumn('id', 'PA:int(3)');
        $this->hasColumn('parent_id', 'N:int(3)');
        $this->hasColumn('name', 'N:varchar(255)');
        $this->hasColumn('path', 'N:varchar(255)');
        $this->hasColumn('project_id', 'int(3)');
    }

    public function initRelations()
    {
        $this->addRelation('Files', new ORMRelationOne2Many('Pfile', 'id', 'folder_id'));
        $this->addRelation('Parent', new ORMRelationOne2One('Pfolder', 'parent_id', 'id'));
        $this->addRelation('Folders', new ORMRelationOne2Many('Pfolder', 'id', 'parent_id'));
        $this->addRelation('Project', new ORMRelationOne2One('Project', 'project_id',  'id'));    
    }

    public function getById($id)
    {
        return parent::getById($id, 'Pfolder');
    }

    public function getByParams( $params, $type = ORMRecord::ONE_RECORD, $limit = null )
    {
        return parent::getByParams( $params, $type, $limit, 'Pfolder');
    }

    public function getAll( $limit = null )
    {
        return parent::getAll( $limit, 'Pfolder' );
    }
}